/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.transas.zorlog.data.log;

import java.nio.ByteBuffer;
import java.text.NumberFormat;
import java.util.List;

/**
 * @author amalikov 
 *
 * Group of Field object
 */
public class PacketParser {

	public PacketParser(List<Field> fields, boolean master) {
		this.fields = fields;
		this.master = master;
	}
	
	public List<Field> getFields() {
		return fields;
	}
	
	public boolean isMaster() {
		return master;
	}
	
	public Double getValue(ByteBuffer buf, int index) {
		return (buf != null) ? fields.get(index).getValue(buf) : 0;
	}

	public String getValueAsString(ByteBuffer buf, int index, NumberFormat nf) {
		return (buf != null) ? fields.get(index).getValueAsString(buf, nf) : "0";
	}
	
	private List<Field> fields;
	private final boolean master;
}
